package com.yangguang.huahui.mvp.model;

import com.yangguang.huahui.api.CommonApi;
import com.yangguang.huahui.entity.Attention;
import com.yangguang.huahui.entity.AttentionList;
import com.yangguang.huahui.entity.Contact;
import com.yangguang.huahui.entity.FlowersType;
import com.yangguang.huahui.entity.Guige;
import com.yangguang.huahui.entity.HttpResult;
import com.yangguang.huahui.entity.PersonInfo;
import com.yangguang.huahui.entity.SelectData;
import com.yangguang.huahui.entity.Sellers;
import com.yangguang.huahui.net.NetManager;
import com.yangguang.huahui.utils.SignUtil;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import okhttp3.ResponseBody;
import rx.Observable;

/**
 * Created by Administrator on 2017/3/2.
 */

public class CommonModel {
    public Observable<Attention> getTabs(){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getTabs();
    }
    public Observable<AttentionList> getListData(String id){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getListData(id);
    }
    public Observable<PersonInfo> getInfo(String uid){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getInfo(uid);
    }

    /**
     * 编辑个人信息
     * @param uid
     * @param paramKey
     * @param paramValue
     * @return
     */
    public Observable<PersonInfo> editInfo(String uid, String paramKey, String paramValue){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        Map<String, String> map = new HashMap<>();
        map.put(paramKey, paramValue);
        map.put("uid", uid);
        return commonApi.editInfo(map, SignUtil.getSign(map));
    }

    public Observable<SelectData> getSelectData(int type){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getSelectData(type);
    }


    public Observable<ResponseBody> getArea(){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getArea();
    }

    public Observable<FlowersType> getFlowers(){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getFlowers_type();
    }

    public Observable<Guige> getNorm(String id){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getNorm(id);
    }

    /**
     * 拉黑
     * @param to_uid
     * @param for_uid
     * @return
     */
    public Observable<HttpResult> add_to_black(String to_uid, String for_uid){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.add_to_black(to_uid, for_uid);
    }

    /**
     * 黑名单
     * @param uid
     * @return
     */
    public Observable<Contact> getBlacklist(String uid){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getBlacklist(uid);
    }

    /**
     * 移除黑名单
     * @param id
     * @return
     */
    public Observable<HttpResult> remove_black(String id){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.remove_black(id);
    }

    /**
     * 添加收藏
     * @param uid
     * @param type
     * @param title_id
     * @return
     */
    public Observable<HttpResult> add_collection(String uid, int type, String title_id){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.add_collection(uid, type, title_id);
    }

    public Observable<ResponseBody> getCollections(String uid, int type){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getCollections(uid, type);
    }

    /**
     * 找客户
     * @param page
     * @param servicearea
     * @param category
     * @param identity
     * @param authentication
     * @return
     */
    public Observable<Sellers> getSellers(int page, String servicearea, String category, String identity, String authentication){
        CommonApi commonApi = NetManager.getInstance().create(CommonApi.class);
        return commonApi.getSellers(page, servicearea, category, identity, authentication);
    }
}
